#pragma once
#include <highgui.h>
#include "stdlib.h"
#include "BasePatch.h"
#include "livingPatch.h"
#include "FrameKey.h"

using namespace std;

class SurfPath : public BasePatch, public LivingPatch<SurfPath>
{
protected:
	float* _desctiptor;  // has poiner, no manage lifecycle
	int _length;

	virtual void OnUpdate(SurfPath* patch)
	{
		memcpy(_desctiptor, patch->_desctiptor, _length*sizeof(float));
	};

public:	
	SurfPath(FrameKey* key, int x, int y, float* descriptor, int length) : 
		BasePatch(key, x, y), 
		LivingPatch(key, x,y), 
		_length(length)		
	{
		_desctiptor = new float[_length];
		memcpy(_desctiptor, descriptor, _length*sizeof(float));		
	}

	void Update(FrameKey* key, int x, int y , float* descriptor)
	{
		UpdateLifecycle(key, x,y);
		memcpy(_desctiptor, descriptor, _length*sizeof(float));
	}

	int GetLength() { return _length; }
	float* GetDescriptor() { return _desctiptor; }

	virtual ~SurfPath() 
	{
		delete []_desctiptor;
	}
};